package com.itheima.pattern.singleton.demo3;

/**
 * 懒汉式
 */
public class Singleton {
    private Singleton(){}

    private static Singleton instance;

    //同步锁解决线程不安全
    public static synchronized Singleton getInstance(){
        if(instance==null){
            instance=new Singleton();
        }
        return instance;
    }
}
